package com.heima.thread.method.priority;

public class Demo {
    public static void main(String[] args) {
        /**
         * setPriority(int newPriority)   设置线程的优先级
         * final int getPriority()        获取线程的优先级
         */

        MyRunnable mr = new MyRunnable();
        Thread t1 = new Thread(mr, "飞机");
        Thread t2 = new Thread(mr, "坦克");

        // 线程默认的优先级是5
        System.out.println(t1.getPriority());
        System.out.println(t2.getPriority());
        System.out.println(Thread.currentThread().getPriority());

        // 线程最大优先级是10, 最小是1
        t2.setPriority(10);
        t1.setPriority(1);

        // 优先级指定的是线程抢占到cpu的概率
        t1.start();
        t2.start();
    }
}
